import 'package:flutter/material.dart';
import 'package:flutterdemo/0demo/provider/02my_demo/provider_test2/shared_data.dart';
import 'package:flutterdemo/0demo/provider/02my_demo/provider_test2/widgets/text_widget.dart';
import 'package:provider/provider.dart';

class ProviderTestPage2 extends StatelessWidget {
  final SharedData _sharedData = SharedData();

  @override
  Widget build(BuildContext context) {
    print("ProviderTestPage2 build");
    return Scaffold(
      appBar: AppBar(
        title: Text("provider test2"),
      ),
      body: MultiProvider(
        providers: [
          ChangeNotifierProvider(create: (_) => _sharedData),
        ],
        child: Container(
          child: Column(
            children: <Widget>[
              FlatButton(
                onPressed: () {
                  _sharedData.updateUserModel();
                },
                child: Text("change user model"),
              ),
              FlatButton(
                onPressed: () {
                  _sharedData.updateGoodModel();
                },
                child: Text("change good model"),
              ),
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceAround,
                children: <Widget>[
                  TextWidget1()
                ],
              )
            ],
          ),
        ),
      ),
    );
  }
}
